package com.cloudsigns.factorymanager2.engineering.presenter;

import com.cloudsigns.factorymanager2.engineering.IView.ICompletionOrderListForMapView;
import com.cloudsigns.factorymanager2.engineering.bean.OrderParentBean;
import com.cloudsigns.factorymanager2.engineering.model.CompletionOrderListForMapModel;
import com.cloudsigns.factorymanager2.engineering.model.ICompletionOrderListForMapModel;

import java.util.List;

public class CompletionOrderListForMapPresenter {

    private ICompletionOrderListForMapView view;
    private ICompletionOrderListForMapModel model;
    private android.os.Handler mHandler = new android.os.Handler();

    public CompletionOrderListForMapPresenter(ICompletionOrderListForMapView view) {
        this.view = view;
        this.model = new CompletionOrderListForMapModel();
    }

    public void getCompletionOrderListForMap() {


        model.getCompletionOrderListForMap(new CompletionOrderListForMapModel.OnCompletionOrderListForMapListener() {
            @Override
            public void getCompletionOrderListForMapSuccessed(final List<OrderParentBean> allOrderList){
                //需要在UI线程执行
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.getCompletionOrderListForMapSuccessed(allOrderList);
                        view.hideLoading();
                    }
                });
            }

            @Override
            public void getCompletionOrderListForMapFailed(final String desc) {
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.getCompletionOrderListForMapFailed(desc);
                        view.hideLoading();
                    }
                });
            }


        });
    }

}
